using System;
using System.Runtime.Serialization;
using RomanJendrusz.Amazon.ETL.Messages;

namespace RomanJendrusz.Amazon.ETL.Exceptions
{
    public class ServiceRequestExecutionException: Exception
    {
        private readonly AmazonRequest request;

        public ServiceRequestExecutionException(AmazonRequest request, string message)
            : base(message)
        {
            this.request = request;
        }

        public ServiceRequestExecutionException(AmazonRequest request)
        {
            this.request = request;
        }

        public ServiceRequestExecutionException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        public ServiceRequestExecutionException(AmazonRequest request, string message, Exception innerException) : base(message, innerException)
        {
            this.request = request;
        }

        public override string Message
        {
            get
            {
                return base.Message + "\r\nRequest that caused the exception: " + request ;
            }
        }
    }
}